#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;


 // Definition for a binary tree node.
    struct TreeNode {
        int val;
          TreeNode *left;
          TreeNode *right;
          TreeNode(int x) : val(x), left(NULL), right(NULL) {}
     };

class Solution {
public:
    TreeNode* mirrorTree(TreeNode* root) {
        if(root == NULL){
            return NULL;
        }
        TreeNode* head = new TreeNode(root->val);
        head->left = mirrorTree(root->right);
        head->right = mirrorTree(root->left);
        return head;
    }
};

int main(){
    Solution S;
    TreeNode* root = new TreeNode(4);
    root->left = new TreeNode(2);
    root->right = new TreeNode(7);
    root->left->left = new TreeNode(1);
    root->left->right = new TreeNode(3);
    root->right->left = new TreeNode(6);
    root->right->right = new TreeNode(9);
    TreeNode* head = S.mirrorTree(root);
    return 0;
}
